package com.zhenhe.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import com.zhenhe.core.common.entity.TUser;
import com.zhenhe.core.common.global.signIn.LoginInfo;
import com.zhenhe.core.common.global.signIn.LoginInfoUtil;

public class RoleTag extends TagSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 186836611048902777L;

	private String needRole;

	@Override
	public int doStartTag() throws JspException {
		LoginInfo info = LoginInfoUtil.getLoginInfo();
		if(info==null||info.getLoginUser()==null||!info.isSignIn()){
			return SKIP_BODY;
		}
		TUser user = info.getLoginUser();
		if(needRole.contains(""+user.getUserRole())){
			return EVAL_BODY_INCLUDE;
		}
		return SKIP_BODY;
	}
	
	
	
	
	
	
	
	
	
	public void setNeedRole(String needRole) {
		this.needRole = needRole;
	}
	
	
	
	
	
}
